<?php 
	include('check_session.php');
	require('conexao.class.php');
	
	$db = new Conexao();
	$conexao = $db->open();
	
	$result = pg_query($conexao, 'Select * from conta_contabils order by id limit 100');
	if (!$result) {
		echo "Ocorreu um erro na consulta dos dados.";
		exit;
	}
	
	$listContas = array();
	$listContas = pg_fetch_all($result);

	$db->close();
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />	
	<title>Lista de Contas</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.css" /><link rel="stylesheet" type="text/css" href="/sidep/css/bootstrap-responsive.css" />
	<link rel="stylesheet" type="text/css" href="css/bootstrap-custom.css" /><link rel="stylesheet" type="text/css" href="/sidep/css/bootstrap-responsive-custom.css" />
	<link rel="stylesheet" type="text/css" href="css/sidep.css" /><script type="text/javascript" src="/sidep/js/jquery-1.7.2.js"></script>	
</head>
<body>
	<br/>
	<div class="container">
    	<div class="row">
			<div class="page">

				<div class="page-header">
					<h2>Lista de Contas Contábeis</h2>
					<div class="page-header-fields">
						<a href="#" class="btn btn-primary"><i class="icon-user icon-white"></i> Boa noite, Sr(a). <?php echo $_SESSION['usuario']['nome']; ?></a>
						<a href="cadastro.php" class="btn btn-primary"><i class="icon-th-list icon-white"></i> Nova Conta</a>		
						<a href="logout.php" class="btn btn-danger"><i class="icon-off icon-white"></i>Sair</a>
					</div>
			
				</div>

				<div class="page-content">	
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>Código</th>
								<th>Conta</th>
								<th>Vida Util</th>
								<th>Taxa Residual</th>
								<th class="actions">Opções</th>
							</tr>
						</thead>
						<tbody>
							<?php foreach ($listContas as $key => $row) { ?>
							<tr>
								<td><?php echo $row['id']; ?></td>
								<td><?php echo $row['descricao']; ?>&nbsp;</td>
								<td><?php echo $row['vida_util']; ?>&nbsp;</td>
								<td><?php echo $row['taxa_residual']; ?>&nbsp;</td>
								<td class="actions">
									<a href="consulta.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-mini"><i class="icon-eye-open icon-white"></i></a>					
								</td>				
							</tr>
							<?php } ?>
						</tbody>
					</table>			
				</div>

   				<div class="page-footer"></div>

			</div>
		
		</div><!--/row-->

    </div><!--/.fluid-container-->
	</body>
</html>
